package nc.ui.capub.tools;

import nc.bs.trade.business.HYPubBO;
import nc.itf.capub.pubitf.IBillMainVO;
import nc.ui.capub.baseui.AbstractBaseUI;
import nc.ui.pub.ClientEnvironment;
import nc.ui.trade.business.HYPubBO_Client;
import nc.vo.capub.basevo.ClientEnvVO;
import nc.vo.capub.basevo.MainbillVO;
import nc.vo.pub.BusinessException;
import nc.vo.pub.SuperVO;
import nc.vo.trade.pub.IBillStatus;

public class DefaultMainVO implements IBillMainVO
{
	@SuppressWarnings("unused")
	private AbstractBaseUI basebill;
	private String  billType;
	private ClientEnvVO env;
	public DefaultMainVO(AbstractBaseUI basebill,String billType)
	{
		this.basebill=basebill;
		this.billType=billType;
	}
	public DefaultMainVO(String billType) {
		this.billType = billType;
	}
	public DefaultMainVO(String billType,ClientEnvVO env) {
		this.billType = billType;
		this.env = env;
	}
	public SuperVO getMainVOByBillType() throws BusinessException
	{
		MainbillVO vo=new MainbillVO();
		ClientEnvironment ce=ClientEnvironment.getInstance();
		String pk_corp=ce.getCorporation().getPk_corp();
		vo.setPk_corp(pk_corp);
		vo.setVbillstatus(IBillStatus.FREE);
		vo.setMakedate(ce.getBusinessDate());
		vo.setVoperatorid(ce.getUser().getPrimaryKey());
		vo.setPk_billtype(billType);
		String billNo=new HYPubBO().getBillNo(billType,pk_corp,null, null);
		vo.setVbillno(billNo);
		return vo;
	}
	public SuperVO getMainVO() throws BusinessException
	{
		MainbillVO vo=new MainbillVO();
		String pk_corp = env.getPk_corp();
        vo.setPk_corp(pk_corp);
		vo.setVbillstatus(IBillStatus.FREE);
		vo.setMakedate(env.getDate());
		vo.setVoperatorid(env.getPk_operator());
		vo.setPk_billtype(billType);
		String billNo=new HYPubBO().getBillNo(billType,pk_corp,null, null);
		vo.setVbillno(billNo);
		return vo;
	}

}
